<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Print 打印 | MyUI 4.x</title>
    <meta name="generator" content="VuePress 1.5.0">
    <link rel="icon" href="/my/favicon.ico">
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?c4e5f73318b5cb0c389e3d9a05f831cc";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
    <meta name="description" content="MyUI是美亚柏科旗下新德汇出品的Web前端一站式项目工程框架，专注于公检法行业中台系统快速搭建，框架已在多个项目实战检验。">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <link rel="preload" href="/my/assets/css/0.styles.3b7da768.css" as="style"><link rel="preload" href="/my/assets/js/app.145deadf.js" as="script"><link rel="preload" href="/my/assets/js/546.c48d7d92.js" as="script"><link rel="preload" href="/my/assets/js/1397.996fb7d1.js" as="script"><link rel="preload" href="/my/assets/js/1234.a1f8d133.js" as="script"><link rel="preload" href="/my/assets/js/974.ffa6c050.js" as="script">
    <link rel="stylesheet" href="/my/assets/css/0.styles.3b7da768.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/my/" class="home-link router-link-active"><img src="/my/img/logo.png" alt="MyUI 4.x" class="logo"> <span class="site-name can-hide">MyUI 4.x</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/my/guide/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link router-link-active">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><a href="/my/ui/pages/" class="nav-link">
  页面
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/my/guide/" class="nav-link">
  指南
</a></div><div class="nav-item"><a href="/my/ui/components/" class="nav-link router-link-active">
  组件
</a></div><div class="nav-item"><a href="/my/ui/charts/" class="nav-link">
  图表
</a></div><div class="nav-item"><a href="/my/ui/map/" class="nav-link">
  地图
</a></div><div class="nav-item"><a href="/my/ui/go/" class="nav-link">
  关系图
</a></div><div class="nav-item"><a href="/my/ui/icon/" class="nav-link">
  图标
</a></div><div class="nav-item"><a href="/my/ui/pages/" class="nav-link">
  页面
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="JSDoc" class="dropdown-title"><span class="title">JSDoc</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my/api/components.html" class="nav-link">
  基础组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/utils.html" class="nav-link">
  工具函数
</a></li><li class="dropdown-item"><!----> <a href="/my/api/charts.html" class="nav-link">
  图表组件
</a></li><li class="dropdown-item"><!----> <a href="/my/api/map.html" class="nav-link">
  地图组件
</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>功能辅助</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/my/ui/components/affix.html" class="sidebar-link">Affix 图钉</a></li><li><a href="/my/ui/components/animate.html" class="sidebar-link">Animate.css 动效</a></li><li><a href="/my/ui/components/capture.html" class="sidebar-link">Capture 抓屏工具</a></li><li><a href="/my/ui/components/clipboard.html" class="sidebar-link">Clipboard 复制剪切</a></li><li><a href="/my/ui/components/drag.html" class="sidebar-link">Drag 拖拽</a></li><li><a href="/my/ui/components/drop.html" class="sidebar-link">Drop 放置</a></li><li><a href="/my/ui/components/flex-tab.html" class="sidebar-link">v-flex-tab指令</a></li><li><a href="/my/ui/components/lazy.html" class="sidebar-link">Lazy 懒加载</a></li><li><a href="/my/ui/components/print.html" aria-current="page" class="active sidebar-link">Print 打印</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my/ui/components/print.html#print-打印" class="sidebar-link">Print 打印</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my/ui/components/print.html#基础用法。" class="sidebar-link">基础用法。</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/print.html#分页处理。" class="sidebar-link">分页处理。</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/print.html#打印-canvas-元素" class="sidebar-link">打印 canvas 元素</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/print.html#样式修正" class="sidebar-link">样式修正</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/print.html#样式改变" class="sidebar-link">样式改变</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/print.html#自定义dom处理方法" class="sidebar-link">自定义DOM处理方法</a></li><li class="sidebar-sub-header"><a href="/my/ui/components/print.html#打印预览" class="sidebar-link">打印预览</a></li></ul></li></ul></li><li><a href="/my/ui/components/promise.html" class="sidebar-link">Promise 异步状态控件</a></li><li><a href="/my/ui/components/resize.html" class="sidebar-link">Resize 缩放</a></li><li><a href="/my/ui/components/sortable.html" class="sidebar-link">Sortable 拖拽排序</a></li><li><a href="/my/ui/components/tree-connect.html" class="sidebar-link">v-tree-connect指令</a></li><li><a href="/my/ui/components/watermark.html" class="sidebar-link">Watermark 水印组件</a></li></ul></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>基础元件</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>排版布局</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>容器修饰</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>导航菜单</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>数据录入</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>数据展示</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>动画效果</span> <span class="arrow right"></span></p> <!----></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="print-打印"><a href="#print-打印" class="header-anchor">#</a> Print 打印</h2> <p>打印工具，可保留打印内容原有的样式。
组件文档 <a href="/my/api/components.html?url=%2Fmy%2Fapi%2Fcomponents%2Fmodule-%24ui_components_my-print.html" target="_blank" data-v-3de95506>MyPrint <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound" data-v-3de95506 data-v-3de95506><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <h3 id="基础用法。"><a href="#基础用法。" class="header-anchor">#</a> 基础用法。</h3> <ul><li>print-range 参数传一个 css 选择器,指定需要打印的区域，如果选择器匹配到多个区域，则会依次分页打印。你可以利用这一特性灵活处理打印内容。</li> <li>打印按钮默认使用 el-button,通过 type,btn-class,text 参数控制按钮显示，如果仍不能满足需求，可通过名称为 button 的插槽自定义元素。</li></ul> <!----><h3 id="分页处理。"><a href="#分页处理。" class="header-anchor">#</a> 分页处理。</h3> <ul><li>如果你希望打印一个表格，每页的行数固定，并且都有表头，可以对表格进行预处理。如代码所示将处理过的表格用.my-print-displaynone 隐藏起来，使用.my-print-visible 在打印时显示出来。</li></ul> <!----><h3 id="打印-canvas-元素"><a href="#打印-canvas-元素" class="header-anchor">#</a> 打印 canvas 元素</h3> <!----><h3 id="样式修正"><a href="#样式修正" class="header-anchor">#</a> 样式修正</h3> <ul><li>如果打印区域内的元素的样式是通过区域外的类限定的，那么打印区域复制后，样式将不起作用。要修正此问题，可以通过给 container-class 参数传入一个类名，作为其容器的类名。如果限定的类大于一层，可以通过 parent-dom 参数传入一个 dom 对象或者一个返回 dom 对象的方法，或者可转为 dom 的字符串，此 dom 对象将作为父容器，内部必须包含 container-class 指定的类名。</li></ul> <!----><h3 id="样式改变"><a href="#样式改变" class="header-anchor">#</a> 样式改变</h3> <ul><li>打印的区域中，可能包含有滚动条的表格，或者折叠起来的项目，你可能希望在打印时将其展开。组件已经默认将el-table的滚动条展开，对于其它的样式，你可以使用style-array传入一个数组去改变相关元素的样式，达到自己想要的效果。数组的每个元素须包含一个css选择器和一个style对象。例如：[{selector: '.wrapper1',style: {height: 'auto'}}]</li></ul> <!----><h3 id="自定义dom处理方法"><a href="#自定义dom处理方法" class="header-anchor">#</a> 自定义DOM处理方法</h3> <ul><li>如果以上方法都不能解决问题，组件提供了一个自定义改变dom的方法dom-transfer, 该方法有两个参数，第一个是组件处理后待打印的dom, 第二个是组件对象本身，你可以通过dom操作改变或添加元素，并返回改变后的dom.</li></ul> <!----><h3 id="打印预览"><a href="#打印预览" class="header-anchor">#</a> 打印预览</h3> <ul><li>在打印前预览打印内容，可以添加preview参数</li></ul> <!----></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/my/ui/components/lazy.html" class="prev">
        Lazy 懒加载
      </a></span> <span class="next"><a href="/my/ui/components/promise.html">
        Promise 异步状态控件
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/my/assets/js/app.145deadf.js" defer></script><script src="/my/assets/js/546.c48d7d92.js" defer></script><script src="/my/assets/js/1397.996fb7d1.js" defer></script><script src="/my/assets/js/1234.a1f8d133.js" defer></script><script src="/my/assets/js/974.ffa6c050.js" defer></script>
  </body>
</html>
